package com.vivo.module.criteria;

public class SimpleCriteriaMetaData<T extends CriteriaMetaData, V> implements
        CriteriaMetaData<T, V> {

	private String key;
	private V value;
	private CriteriaValidator<V> validator = null;

	/**
	 * Constructor
	 */
	public SimpleCriteriaMetaData(String key) {
		this.key = key;
	}

	public SimpleCriteriaMetaData(String key, CriteriaValidator<V> validator) {
		this.key = key;
		this.validator = validator;
	}

	public T addValue(V value) {
		this.value = value;
		if (this.validator != null) {
			this.validator.validate(value);
		}
		return (T) this;
	}

	public String getKey() {
		return key;
	}

	public V getValue() {
		return value;
	}

}
